﻿var checkLength = function(str,length){
	if(str.length>=length){
		return true;
	}else{
		return false;
	}
}
//检查userinfo表
exports.checkUserinfo = function(userid,username,password,sex,birthday,phoneNum,email){
	console.log(userid+username+password+sex+birthday+phoneNum+email);
	//userid
	if(checkLength(userid,200)){
		return false;
	}
	if(userid===undefined||userid===''){
		return false;
	}
	console.log("username")
	//username
	if(username!=undefined){
		if(checkLength(username,200)){
			return false;
		}
	}	
	
	//password
	if(password!=undefined){
		if(checkLength(password,200)){
			return false;
		}
	
		if(password.length<6){
			return false;
		}
	}
	console.log("sex")
	//sex
	if(sex!=undefined){
		if(checkLength(sex,10)){
			return false;
		}
		if(sex!="男"&&sex!="女"){
			return false;
		}
	}
	
	//birthday
	if(birthday!=undefined){
		if(checkLength(birthday,100)){
			return false;
		}
	}
	//phoneNum
	if(phoneNum!=undefined){
		if(checkLength(phoneNum,100)){
			return false;
		}
		if(isNaN(phoneNum)){
			return false;
		}
	}
	//email
	if(email!=undefined){
		if(checkLength(email,100)){
			return false;
		}
	}
	return true;
};
//检查note表
exports.checkNote = function(userid,type,content,isDelete){
	//userid
	if(checkLength(userid,200)){
		return false;
	}
	if(userid===undefined||userid===''){
		return false;
	}
	//type
	if(checkLength(type,200)){
		return false;
	}
	//content
	if(checkLength(content,200)){
		return false;
	}
	//isDelete
	if(isDelete>10||isDelete<0){
		return false;
	}
	return true;
	
}